Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/75 no mkdir when s3 #76

Merged
merged 2 commits into from
Feb 27, 2024
Merged

Fix/75 no mkdir when s3 #76

merged 2 commits into from
Feb 27, 2024

Conversation

lchen-2101
Copy link
Collaborator

closes #75

Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/services
  submission_processor.py
Project Total  

This report was generated by python-coverage-comment-action


log = logging.getLogger(__name__)


async def upload_to_storage(lei: str, submission_id: str, content: bytes, extension: str = "csv"):
try:
fs: AbstractFileSystem = filesystem(settings.upload_fs_protocol.value)
fs.mkdirs(f"{settings.upload_fs_root}/{lei}", exist_ok=True)
if settings.upload_fs_protocol == FsProtocol.FILE:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the LocalFileSystem impl takes a auto_mkdir boolean which would create the directory on open if it doesn't exist, that could be passed in kwargs to open I think. If so, this might be a good way to avoid this impl specific if (which loses the abstractness which is really nice to have!). The kwarg would get ignored by S3. I'm not positive, just reading the API, but might be worth a look?

If that doesn't work, this looks good. Just was hoping to keep it all abstract but alas!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really good suggestion, alas it doesn't work... I get an unexpected keyword argument, so unfortunately the s3fs doesn't ignore it...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BOOO. Oh well

Copy link
Contributor

@jcadam14 jcadam14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@jcadam14 jcadam14 merged commit 30cd0b7 into main Feb 27, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix file upload so mkdir isn't called if protocol is S3
2 participants